﻿package  com.athena.controller
{
	import flash.events.*;
	import flash.utils.*;
	import flash.text.TextFormat;
	import com.adobe.serialization.json.JSON;
	import flash.net.URLRequest ;
	import flash.net.URLLoader;
	import flash.net.URLVariables ;
	import flash.net.URLRequestMethod ;
	import flash.net.URLRequestHeader ;
	import flash.display.*;
	import com.athena.vo.*;
	import com.athena.controller.*;
	import com.athena.process.*;
	import fl.containers.ScrollPane; 
	import fl.controls.ScrollPolicy; 
	import flash.net.navigateToURL;	
	/**
	 * ...
	 * @author Tamnt
	 */
	public class AuctionController 
	{
		var movie_mc : MovieClip;
		var objMain : Object ;
		public function AuctionController(_mc:MovieClip, _obj : Object) 
		{
			movie_mc = _mc;
			objMain = _obj ;
			_mc.Name_txt.text = _obj.N ;
			var startTime : Date = new Date(_obj.ST) ;
			_mc.Time_txt.text = startTime.getDate().toString() + "/" + (startTime.getMonth() + 1).toString() + "/" + startTime.getFullYear().toString() ;
			_mc.Price_txt.text = BasicFunction.numberFormat(_obj.P, 0, false, true) + " Đồng" ;
			if (_obj.AT == 1)
				_mc.FeeAG_txt.text = BasicFunction.numberFormat(_obj.PS, 0, false, true) + " LQ" ;
			else
				_mc.FeeAG_txt.text = BasicFunction.numberFormat(_obj.PS, 0, false, true) + " AG" ;
			movie_mc.addEventListener(MouseEvent.CLICK, click);
			var formatText : TextFormat ;
			formatText = new TextFormat() ;				
			formatText.bold = true ;
			_mc.Name_txt.setTextFormat(formatText) ;
			_mc.Price_txt.setTextFormat(formatText) ;			
			_mc.Time_txt.setTextFormat(formatText) ;
			if (_obj.AT == 1)
				formatText.color = 0x0000A0 ;
			_mc.FeeAG_txt.setTextFormat(formatText) ;
			var imageLoader:Loader = new Loader();
			var image:URLRequest = new URLRequest(_obj.I) ;
			imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoader);				
			imageLoader.name = "BigAW" ;
			imageLoader.load(image);				
			function onLoader(evt:Event)
			{
				imageLoader.width = 80 ;
				imageLoader.height = 80 ;
				_mc.Image_mc.addChild(imageLoader);
			}			
		}		
		public function click(evt:MouseEvent):void
		{
			//AuctionFunction.LoadSanpham(objMain.Id) ;
		}
	}
}